﻿#region COPYRIGHT© 2009-2013 Phillip Clark. All rights reserved.

// For licensing information see License.txt (MIT style licensing).

#endregion

using System;

namespace FlitBit.Core.Parallel
{
	/// <summary>
	///   Continuation delegate.
	/// </summary>
	/// <param name="fault">an exception raised by the operation</param>
	/// <remarks>
	///   Continuations are invoked when the operation on
	///   which they depend reaches completion. Continuations always
	///   receive an exception as their first argument. In success
	///   cases, the <paramref name="fault" /> argument will be null; otherwise
	///   it is the exception raised by the operation being continued.
	/// </remarks>
	public delegate void Continuation(Exception fault);

	/// <summary>
	///   Continuation delegate.
	/// </summary>
	/// <typeparam name="T">item type T, usually the result type of the operation being continued.</typeparam>
	/// <param name="fault">an exception raised by the operation</param>
	/// <param name="item">the result of the continued operation (when the operation is a Fun&lt;>)</param>
	/// <remarks>
	///   Continuations are invoked when the operation on
	///   which they depend reaches completion. Continuations always
	///   receive an exception as their first argument. In success
	///   cases, the <paramref name="fault" /> argument will be null; otherwise
	///   it is the exception raised by the operation being continued.
	/// </remarks>
	public delegate void Continuation<in T>(Exception fault, T item);

	/// <summary>
	///   Continuation delegate.
	/// </summary>
	/// <typeparam name="TResult">result type R</typeparam>
	/// <param name="fault">an exception raised by the operation</param>
	/// <returns>a return item</returns>
	/// <remarks>
	///   Continuations are invoked when the operation on
	///   which they depend reaches completion. Continuations always
	///   receive an exception as their first argument. In success
	///   cases, the <paramref name="fault" /> argument will be null; otherwise
	///   it is the exception raised by the operation being continued.
	/// </remarks>
	public delegate TResult ContinuationFunc<out TResult>(Exception fault);

	/// <summary>
	///   Continuation delegate.
	/// </summary>
	/// <typeparam name="T">item type T, usually the result type of the operation being continued.</typeparam>
	/// <typeparam name="TResult">result type R</typeparam>
	/// <param name="fault">an exception raised by the operation</param>
	/// <param name="item">the result of the continued operation (when the operation is a Fun&lt;>)</param>
	/// <returns>a return item</returns>
	/// <remarks>
	///   Continuations are invoked when the operation on
	///   which they depend reaches completion. Continuations always
	///   receive an exception as their first argument. In success
	///   cases, the <paramref name="fault" /> argument will be null; otherwise
	///   it is the exception raised by the operation being continued.
	/// </remarks>
	public delegate TResult ContinuationFunc<in T, out TResult>(Exception fault, T item);
}